/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package be;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * Sistema de Control Acádemico (saca) creado por Buñay Paulo
 */
@Entity
@Table(name = "MATERIA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Materia.findAll", query = "SELECT m FROM Materia m"),
    @NamedQuery(name = "Materia.findByIdMateria", query = "SELECT m FROM Materia m WHERE m.idMateria = :idMateria"),
    @NamedQuery(name = "Materia.findByNombreMateria", query = "SELECT m FROM Materia m WHERE m.nombreMateria = :nombreMateria"),
    @NamedQuery(name = "Materia.findByDescripcion", query = "SELECT m FROM Materia m WHERE m.descripcion = :descripcion")})
public class Materia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_MATERIA")
    private Integer idMateria;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "NOMBRE_MATERIA")
    private String nombreMateria;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 170)
    @Column(name = "DESCRIPCION")
    private String descripcion;
    @JoinColumn(name = "ID_ESTADO_MATERIA", referencedColumnName = "ID_ESTADO_MATERIA")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private EstadoMateria estadoMateria;
    @JoinColumn(name = "ID_TIPO_MATERIA", referencedColumnName = "ID_TIPO_MATERIA")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoMateria tipoMateria;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "materia", fetch = FetchType.LAZY)
    private List<DetalleAlumnoCursoQuimestre> detalleAlumnoCursoQuimestreList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "materia", fetch = FetchType.LAZY)
    private List<DetalleDocenteAnioLectivoMateria> detalleDocenteAnioLectivoMateriaList;

    public Materia() {
    }

    public Materia(Integer idMateria) {
        this.idMateria = idMateria;
    }

    public Materia(Integer idMateria, String nombreMateria, String descripcion) {
        this.idMateria = idMateria;
        this.nombreMateria = nombreMateria;
        this.descripcion = descripcion;
    }

    public Integer getIdMateria() {
        return idMateria;
    }

    public void setIdMateria(Integer idMateria) {
        this.idMateria = idMateria;
    }

    public String getNombreMateria() {
        return nombreMateria;
    }

    public void setNombreMateria(String nombreMateria) {
        this.nombreMateria = nombreMateria;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public EstadoMateria getEstadoMateria() {
        return estadoMateria;
    }

    public void setEstadoMateria(EstadoMateria estadoMateria) {
        this.estadoMateria = estadoMateria;
    }

    public TipoMateria getTipoMateria() {
        return tipoMateria;
    }

    public void setTipoMateria(TipoMateria tipoMateria) {
        this.tipoMateria = tipoMateria;
    }

    @XmlTransient
    public List<DetalleAlumnoCursoQuimestre> getDetalleAlumnoCursoQuimestreList() {
        return detalleAlumnoCursoQuimestreList;
    }

    public void setDetalleAlumnoCursoQuimestreList(List<DetalleAlumnoCursoQuimestre> detalleAlumnoCursoQuimestreList) {
        this.detalleAlumnoCursoQuimestreList = detalleAlumnoCursoQuimestreList;
    }

    @XmlTransient
    public List<DetalleDocenteAnioLectivoMateria> getDetalleDocenteAnioLectivoMateriaList() {
        return detalleDocenteAnioLectivoMateriaList;
    }

    public void setDetalleDocenteAnioLectivoMateriaList(List<DetalleDocenteAnioLectivoMateria> detalleDocenteAnioLectivoMateriaList) {
        this.detalleDocenteAnioLectivoMateriaList = detalleDocenteAnioLectivoMateriaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMateria != null ? idMateria.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Materia)) {
            return false;
        }
        Materia other = (Materia) object;
        if ((this.idMateria == null && other.idMateria != null) || (this.idMateria != null && !this.idMateria.equals(other.idMateria))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "be.Materia[ idMateria=" + idMateria + " ]";
    }

}
